<template>
  <div class="app-container">
    <el-card style="height: 260px">
      <h3 class="title-left">预定会议室</h3>
      <el-divider style="border-width: thin"></el-divider>
      <el-button @click="returnUp" class="retu">返回</el-button>
      <image-preview :src="image" :width="230" :height="150" style="float: left;margin-left: 210px"/>
      <div class="content">
        <span class="title">{{ name }}</span>
        <div class="fontLine">
          <span class="count">坐席{{ count }}</span>
          <span class="position">{{ position }}</span>
        </div>
<!--        <div class="tagLine">
          <el-tag class="tag" type="info" size="mini" color="white" effect="light" v-for="tag in device">{{ tag }}</el-tag>
        </div>-->
      </div>
      <div style="width: 150px;height: 70px;font-size: 15px;">
        <span style="position: absolute;right:60px;top:140px;display: block">备注：{{ common }}</span>
        <span style="position: absolute;right:60px;top:165px;display: block">会议日期：{{ datee }} {{startDate}}至{{endDate}}</span>
        <span style="position: absolute;right:60px;top:190px;display: block">会议时长：{{ duration }}分钟</span>
      </div>
    </el-card>
    <el-card class="box-card" style="margin-top: 10px">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="会议主题">
        <el-input v-model="form.title" suffix-icon="el-icon-date" placeholder="请输入会议主题" style="width: 400px"></el-input>
      </el-form-item>
      <el-form-item label="参会人数">
        <el-input-number v-model="form.number" :min="1" :max="100" label="描述文字"></el-input-number>
<!--        <el-input v-model="form.number" suffix-icon="el-icon-date" placeholder="请输入参会人数" style="width: 400px"></el-input>-->
      </el-form-item>
      <el-form-item label="主持人">
        <el-select v-model="form.host" placeholder="请选择主持人">
          <el-option v-for="host in hostList" :key="host" :label="host" :value="host"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="会议描述">
        <el-input type="textarea" :rows="4" style="width: 500px" placeholder="请输入会议描述" v-model="form.description"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleSubmit">提交</el-button>
        <el-button @click="handleCancel">取消</el-button>
      </el-form-item>
    </el-form>

    </el-card>
  </div>
</template>
<style>
.title-left{
  position: relative;
  padding-left: 13px;
  margin: 2px 0
}
.title-left:before{
  content: "";
  background-color: #3796EC;
  width: 5px;
  height: 17px;
  position: absolute;
  left: 5px;
  top: 45%;
  margin: -8px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}
.content{
  margin: 15px 0 0 25px;
  float: left;
  width: 200px;
  height: 90px;
}
.title{
  font-weight: bold;
  font-size: 20px;
  display: block;
  float: left;
  margin-bottom: 0;
}
.fontLine{
  float: left;
  margin-right: 40px;
}
.count{
  float: left;
  margin: 10px 20px 0 0;
}
.position{
  float: left;
  margin-top: 10px;
}
.tagLine{
  float: left;
  margin-top: 15px;
  margin-left: -8px;
  width: 280px;
  height: 30px;
}
.tag{
  float: left;
  color: black;
  margin-left: 5px;
}
.retu{
  position: absolute;
  left: 50px;
}
</style>
<script>
import { getRoom } from "@/api/system/room";
import { getEmpNames } from '@/api/system/emplyee'
import { addAppointment } from '@/api/system/appointment'

export default {
  name: "Room",
  dicts: ['sys_meetting_status'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 会议室信息表表格数据
      roomList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      image:'',
      name:'',
      count:'',
      position:'',
      device: '',
      status:'',
      common:'',
      datee:'',
      startDate:'',
      endDate:'',
      duration:'',
      meettingId:null,
      hostList:null,
      // 表单参数
      form: {
        number: 1,
      },
      //设备备选值
      deviceOptions:['投影仪','白板','电脑','空调','沙发'],
      startTime: '',
      endTime: '',
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.datee = this.$route.params && this.$route.params.datee;
    this.startDate = this.$route.params && this.$route.params.startDate;
    this.endDate = this.$route.params && this.$route.params.endDate;
    this.meettingId = this.$route.params && this.$route.params.id;
    this.duration = this.$route.params && this.$route.params.duration
    this.getList(this.meettingId);
    getEmpNames().then(res => {
      this.hostList = res;
    });
  },
  methods: {
    /** 查询会议室信息表列表 */
    getList(meettingId) {
      this.loading = true;
      getRoom(meettingId).then(res => {
        this.image = res.data.image;
        this.name = res.data.name;
        this.count = res.data.count;
        this.common = res.data.common;
        this.position = res.data.position;
        this.status = res.data.status;
        this.device = JSON.parse(JSON.stringify(res.data.device)).split(',');
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },

    // 表单重置
    reset() {
      this.form = {
        id: null,
        image: null,
        name: null,
        count: null,
        position: null,
        device: [''],
        status: null,
        common: null
      };
      this.resetForm("form");
    },
    returnUp(){
      const obj = { path: "/logistics/meetting/appoint" };
      this.$tab.closeOpenPage(obj);
    },
    /** 提交按钮 */
    handleSubmit() {
      var obj = {
        meettingId : this.meettingId,
        datee : this.datee,
        startDate : this.startDate,
        endDate : this.endDate,
        promoter : this.form.host,
        duration : this.duration,
        title : this.form.title,
        host : this.form.host,
        number : this.form.number,
        description : this.form.description,
        status : '1'
      }
      addAppointment(obj).then(response => {
        this.$modal.msgSuccess("提交成功");
        this.open = false;
        const obj = { path: "/logistics/meetting/appoint" };
        this.$tab.closeOpenPage(obj);
      });
    },
    handleCancel(){
      const obj = { path: "/logistics/meetting/appoint" };
      this.$tab.closeOpenPage(obj);
    }
  }
};
</script>
